  export function changeUseName(data){
    return {
      type:"CAHNGNAME",
      data
    }
  }
  export function loginState(){
    return {
      type:"FALSELOGIN"
    }
  }
  
  export function userLogin(user={name:0,password:0}){
    return dispatch=>{
      return fetch('http://10.31.153.45:3000/users/login',{
        method: "POST",
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        },
        body:"name="+user.name+"&password="+ user.password
      })
      .then(res=>{    
        return res.json()
      })
      .then(data=>{ 
        if(data.name){
          dispatch(changeUseName(data))       
        }else{
          dispatch(loginState())   
        }
       
      })
    }  
  }